﻿using CTP.CRM.Core.SqlSugar.Entitys;
using CTP.CRM.Repository;
using CTP.CRM.Repository.VSystemRepository.Entitys;
using System.Linq.Expressions;
using Volo.Abp.DependencyInjection;

namespace CTP.CRM.Repository.VSystemRepository.Services
{
    public class VSystemRepository : BasicRepository<VSystemEntity>, IVSystemRepository, IScopedDependency
    {
        /// <summary>
        /// 根据主键软删除（可批量）
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public Task<int> SoftDeleteAsync(params int[] ids)
        {
            return Context.Deleteable<VSystemEntity>().In(ids).IsLogic().ExecuteCommandAsync(nameof(IDeleteBasicEntity.IsDeleted));
        }

        /// <summary>
        /// 根据主键软删除（可批量）
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public VSystemEntity FirstOrDefault(Expression<Func<VSystemEntity, bool>> where)
        {
            return Context.Queryable<VSystemEntity>().Where(where).First();
        }
    }
}